/**
 * 功能描述
 */

define(function (require, exports, module) {
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper");
	var user = require("store").get("user");
    var instance = {
        initComponent: function (params,widget) {
        	var subnav = new Subnav({
        		parentNode:".J-subnav",
        		model:{
        			title:"员工充值",
        			items:[{
						id:"search",
						type: "search",
						placeholder: "会员名/身份证号",
						handler: function(str){
							aw.ajax({
								url: "api/attendant/search",
								data: {
									s: str,
									searchProperties: "personalInfo.name,personalInfo.idNumber",
									fetchProperties:"*,personalInfo.name,personalInfo.sex,personalInfo.idNumber"
								},
								success: function(data){
									widget.get("grid").setData(data);
								}
							});
						}
            		},{
						id : "servicePoint",
						text : "服务点",
						tip : "服务点",
//						url:"api/servicepoint/operableservicepoints",
//						lazy:true,
						items:user.privateServicePoints,
						type : "buttongroup",
						keyField : "pkServicePoint",
						valueField : "name",
						all: {
							show: false,
							position: "bottom"
						},
						handler:function(key,element){	
							widget.get("grid").refresh();
						}
            		},{
            			id:"back",
            			text:"返回",
            			type:"button",
            			handler:function(){
            				widget.show([".J-grid"]).hide([".J-Egrid"]);
    						widget.get("subnav").show(["servicePoint","search"]).hide(["back"]);
            			}
            		}]
        		}
        	});
        	widget.set("subnav",subnav);
        }
    };
    module.exports = instance;
});
